<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="inicio.xhtml">
        <ui:define name="content">
            <p:panel id="panelFoto" styleClass="centro painel">
                <h:link value="Criar album" outcome="album.xhtml" />
                <br /><br /> 
                <h:outputText id="textoAlbum" value="Você não tem nenhum album" rendered="#{usuarioMB.renderTextoAlbum}" /> 
                <h:form>
                    <ui:repeat value="#{usuarioMB.usuario.albuns}" var="album">
                        <p:panelGrid columns="4" columnClasses="1, 2, 3, 4" styleClass="panelGridAlbum">
                            <p:graphicImage value="#{album.capa}" width="50px" height="50px"/>
                            <p:panel styleClass="panelTitulo" >
                                <h:outputText value=" #{album.titulo} " />
                            </p:panel>
                            <p:panel styleClass="panelDescricao" style="padding: 0px">
                                <h:outputText value=" #{album.descricao} " />
                            </p:panel>
                            <h:column>
                                <p:commandButton id="excluir" onclick="confirmExcluir.show();" action="#{albumMB.selecionaAlbum}" icon="ui-icon-circle-close" >
                                    <f:setPropertyActionListener value="#{album.codigo}" target="#{albumMB.id}" />
                                </p:commandButton>
                                <p:commandButton id="ver" action="#{albumMB.selecionaAlbumView}" icon="ui-icon-folder-open">
                                    <f:setPropertyActionListener value="#{album.codigo}" target="#{albumMB.id}" />
                                </p:commandButton>
                                <p:commandButton id="editar" action="#{albumMB.selecionaAlbumEditar}" icon="ui-icon-document">
                                    <f:setPropertyActionListener value="#{album.codigo}" target="#{albumMB.id}" />
                                </p:commandButton>
                            </h:column>
                        </p:panelGrid>
                        <p:dialog id="confirmation" widgetVar="confirmExcluir" style="text-align: center">
                            <h:outputText value="Tem certeza que deseja excluir o album?" />
                            <br /><br />
                            <p:commandButton id="confirm" value="Sim" action="#{albumMB.excluir}" 
                                             ajax="true" update="@all" onclick="confirmExcluir.hide();"/>
                            <p:commandButton id="decline" value="Não" onclick="confirmExcluir.hide();" type="button" />   
                        </p:dialog>
                        <br />
                    </ui:repeat>
                </h:form>
            </p:panel> 
        </ui:define>
    </ui:composition>
</html>

